package day03;
/*
 * 线程1：用来加载图片
 * 打印1%~100%
 * 打印加载完成
 * 开始下载图片
 * 打印1%~100%
 * 打印下载完成
 * 线程2：用来显示图片
 * 打印显示完成
 */

public class T1up {

	public static void main(String[] args) throws InterruptedException {
		Object ooo=new Object();
		Thread p=new Thread(new Runnable() {

			@Override
			public void run() {
				System.out.println("开始加载");
				for(int i=1;i<101;i++) {
					System.out.println("加载进度："+i+"%");
					try {
						Thread.sleep(20);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

				synchronized(ooo) {
					try {
						ooo.wait();
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				System.out.println("开始打印");
				for(int i=1;i<101;i++) {
					System.out.println("打印进度+"+i+"%");
				}	
				System.out.println("打印完成");
				
			}		
		});

		Thread q=new Thread(new Runnable() {

			@Override
			public void run() {
				synchronized(ooo) {
				ooo.notifyAll();
				}
			}

			
		});
		p.start();
		q.start();
	}

}
